<?php

class Form_Join extends Zend_Form {

    public function init() {

        $this->setAction("/user/register");
        $this->setMethod ( 'post' );

        $decorator = array(
                        'ViewHelper',
                        'Errors',
                        array(array('data' => 'HtmlTag'), array('tag' => 'span', 'class' => 'data')),
                        array('Label', array('tag' => 'div'),
                        array(array('row' => 'HtmlTag'), array('tag' => 'span')),
                    ));

        $this->addElement ( 'text', 'email', array ('decorators' => $decorator, 'label' => 'Your email:', 'required' => true, 'filters' => array ('StringTrim' ), 'validators' => array ('EmailAddress' ) ) );

        $this->addElement ( 'text', 'username', array ('decorators' => $decorator, 'label' => 'Choose a nickname:', 'filters' => array ('StringTrim', 'StringToLower' ),
            'validators' => array ('alnum', array ('regex', false, array ('/^[a-z]/i' ) ), array ('StringLength', false, array (3, 20 ) ) ), 'required' => true )
        );

        $this->addElement ( 'password', 'password1', array ('decorators' => $decorator, 'filters' => array ('StringTrim' ), 'validators' => array (array ('StringLength', false, array (5, 20 ) ) ), 'required' => true,
            'label' => 'Choose your password:' ) );

        $this->addElement ( 'password', 'password2', array ('decorators' => $decorator, 'filters' => array ('StringTrim' ), 'validators' => array (array ('StringLength', false, array (5, 20 ) ) ), 'required' => true,
            'label' => 'Insert your password (yep, again):' ) );

        $this->addElement ( 'submit', 'submit',
                array ('label' => 'Join',
                     'class' => 'large') );

    }
}

